<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="{{ url_for('static', filename='css/bootstrap.min.css') }}">
    <title>Steam Games</title>
</head>

<body>
    <nav class="navbar navbar-expand-lg navbar-light bg-light">
        <a class="navbar-brand" href="/">Steam Games</a>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav"
            aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarNav">
            <ul class="navbar-nav">
                <li class="nav-item active">
                    <a class="nav-link" href="/">Home <span class="sr-only">(current)</span></a>
                </li>
            </ul>
        </div>
    </nav>

    <div class="container mt-4">
        <div class="jumbotron" style="text-align: center;">
            <h1 class="display-4">Steam Top 100 Games!</h1>
            <p class="lead">All the games here are scraped from Official Steam Store using Scrapy & ScrapyRT.</p>
            <hr class="my-4">
            <p>For furthur info, please chick the button below.</p>
            <a class="btn btn-primary btn-lg" href="https://scrapy.org" role="button" target="_blank">Learn more</a>
        </div>
    </div>

    <div class="container">
        {% for game in games %}
            {% if loop.index0 % 3 == 0 %}
                <div class="row justify-content-center mt-4 mb-4">
            {% endif %}

            <div class="card mr-4" style="width: 18rem; text-align: center;">
                <img src="{{game.get('img_url')}}" class="card-img-top">
                <div class="card-body d-flex flex-column">
                    <h5 class="card-title align-self-center">{{game.get('game_name')}}</h5>
                    <p class="card-text align-self-center" style="margin-top: auto;">Supported Platforms: {{game.get('platforms')}}</p>
                    <a href="{{game.get('game_url')}}" class="btn btn-primary align-self-center" target="_blank" style="margin-top: auto;">Buy Now</a>
                </div>
            </div>

            {% if loop.index0 % 3 == 2 %}
                </div>
            {% endif %}
        {% endfor %}
    </div>
</body>

</html>